//
//  YJSalesTopicListCell.m
//  SnackCourier
//
//  Created by qianfeng01 on 15/7/18.
//  Copyright (c) 2015年 qianfeng01. All rights reserved.
//

#import "YJSalesTopicListCell.h"
#import "YJSalesTopicListView.h"
@implementation YJSalesTopicListCell

- (void)awakeFromNib {
    CGFloat w=self.contentView.frame.size.width/2.0;
    CGFloat h =self.contentView.frame.size.height;
    for (int i=0; i<3; i++) {
        NSArray *nib =[[NSBundle mainBundle] loadNibNamed:@"YJSalesTopicListView" owner:self options:nil];
        _sView =nib.lastObject;
        if (i==0) {
            _sView.frame =CGRectMake(1, 1, w-1, h-1);
        }else{
            _sView.frame =CGRectMake(w+1, (i-1)*(h/2.0)+1, w, (h/2.0-1));
        }
        _sView.tag =101+i;
        [self.contentView addSubview:_sView];
    }
    
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

-(void)showDataWithArray:(NSMutableArray *)array myblock:(YJSalesTopicListBlock)myblock{
    self.array =array;
    self.myBlock =myblock;
    for (int i=0; i<array.count; i++) {
        YJSalesTopicListView *Sview =(YJSalesTopicListView *)[self.contentView viewWithTag:i+101];
        [Sview showDataWithModel:array[i]];
        [Sview addTarget:self action:@selector(Click:)];
    }
}
-(void)Click:(YJSalesTopicListView *)view{
    if (self.myBlock) {
        YJSalesTopicListModel *model =self.array[view.tag-101];
        self.myBlock(model);
    }
}

@end
